var express = require('express')
const router = express.Router()
const path = require('path')
const fs = require('fs')


router.use(function(req, res, next){
    console.log('做当前路由下 权限拦截')
    next()
})
router.post('/queryMessageRecordList', function(req, res){
    var file = path.join(__dirname, '../', '/JSON/queryMessageRecordList.json'); //文件路径，__dirname为当前运行js文件的目录
	console.log('请求进来')
	//读取json文件
    fs.readFile(file, 'utf-8', function(err, data) {
        if (err) {
            res.send('文件读取失败');
        } else {
            res.send(data);
        }
    });
})
router.post('/submitBatchSendMessage', function(req, res){
	res.send({
        "msg": "获取成功",
        "code": 200,
        "data": "12345"
    })
})
router.post('/queryMessageTemplateList', function(req, res){
	res.send({
        "msg": "获取成功",
        "code": 200,
        "data": [
            {
                "templateCode": "1",
                "templateType": "IVR",
                "templateChannel": "YLB",
                "templateSign": "模版签名",
                "templateTitle": "模板标题:IVR",
                "templateParseType": "OUTER",
                "templateSource": "id",
                "remark": "",
                "extraInfo": ""
            },{
                "templateCode": "1",
                "templateType": "FLASH",
                "templateChannel": "YLB",
                "templateSign": "模版签名",
                "templateTitle": "模板标题:FLASH",
                "templateParseType": "OUTER",
                "templateSource": "id",
                "remark": "",
                "extraInfo": ""
            },{
                "templateCode": "1",
                "templateType": "SMS",
                "templateChannel": "YLB",
                "templateSign": "模版签名",
                "templateTitle": "模板标题:SMS",
                "templateParseType": "OUTER",
                "templateSource": "id",
                "remark": "",
                "extraInfo": ""
            }
        ]
    })
})
module.exports = router